package com.visec.hdy.config;

import java.util.HashMap;
import java.util.Map;

import com.visec.hdy.utils.ParameterHandle;

public class PCVHandle {
	private ParameterCV<?>[] parameterCVs;
	private Map<Class<?>, Object> result;

	public PCVHandle(ParameterCV<?>... ps) {
		parameterCVs = ps;
		result = new HashMap<Class<?>, Object>();
	}

	public void conversion(String[] s) {
		Map<String, String> strArryToMap = ParameterHandle.strArryToMap(s);
		conversion(strArryToMap);
	}

	public void conversion(Map<String, String> m) {
		if (m == null)
			return;
		for (ParameterCV<?> p : parameterCVs) {
			p.setParams(m);
			Object parameter = p.getParameter();
			result.put(parameter.getClass(), parameter);
		}
	}

	public <T> T getTarget(Class<T> c) {
		return (T) result.get(c);
	}

	
}
